#
#   Hello World server in Python
#   Binds REP socket to tcp://*:5555
#   Expects b"Hello" from client, replies with b"World"
#

import bsm_msgs_pb2
import zmq

context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5555")

BSM_multi = bsm_msgs_pb2.BSM_multi()
while True:
    #  Wait for next request from client
    message = socket.recv()
    socket.send_string('done')
    BSM_multi.ParseFromString(message)
    for BSM in BSM_multi.data:
        print("id:{}, lat:{}, lon:{}"
              .format(BSM.idbuf, BSM.lat, BSM.lon))
